<!-- text按钮 -->
<template>
  <div class="btn-text-main">
    <div class="btn-text" @click.stop="openClick">
      <span v-if="isIcon"><img :src="iconArr[iconName]" /></span>
      <span :class="type">
        <slot></slot>
      </span>
    </div>
  </div>
</template>

<script type="text/javascript">
import icon_1 from "@/assets/icon/icon_t (8).png";

export default {
  name: "btn-text",
  props: {
    type: {
      type: String,
      default: "text",
    },
    isIcon: {
      type: Boolean,
      default: false,
    },
    iconName: {
      type: String,
      default: "icon_1",
    },
  },
  data() {
    return {
      iconArr: {
        icon_1, // 图片
      },
    };
  },
  methods: {
    openClick() {
      this.$emit("BtnClick");
    },
  },
};
</script>

<style lang="less" scoped>
.btn-text-main {
  padding: 5px;
  font-size: 14px;
  display: inline-block;
  .btn-text{
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap; /* 强制不换行 */
    img{
      display: block;
      height: 20px;
    }
    span:nth-child(1){
      margin-right: 5px;
    }
    span{
      display: block;
      height: 20px;
      line-height: 20px;
      font-size: 14px;
    }
  }
  .text {
    color: #999;
  }
  .primary {
    color: #2d8cf0;
  }
  .warning {
    color: #f90;
  }
  .error {
    color: #ed4014;
  }
  .success {
    color: #19be6b;
  }
  .green {
    color: #1ccad5;
  }
}
</style>
